Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix date time and complex datation validations #20

Draft
wants to merge 10 commits into
base: development
Choose a base branch
from

Conversation

abstracts33d
Copy link

@abstracts33d abstracts33d commented Apr 30, 2024

script d'export des records en erreur de validation ( + de 6000 records)

file = "#{Rails.root}/condensed_item_list.csv"

CSV.open(file, 'w') do |csv|
  ItemType.joins(:fields).where(fields: {type: ["Field::ComplexDatation", "Field::DateTime"]}).find_each do |item_type|
    item_type.items.find_each do |item|
      unless item.behaving_as_type.valid?
        errors = item.behaving_as_type.errors.select{|error| field = Field.find_by(uuid: error.attribute); field.is_a?(Field::DateTime) || field.is_a?(Field::ComplexDatation)}
        next if errors.empty?
        
        csv << [
          item.catalog.id,
          item.catalog.name,
          item.catalog.slug,
          item.item_type.id,
          item.item_type.slug,
          item.id,
          errors.map{|error| {attribute: error.attribute, message: error.message}}.to_s,
          Field.where(uuid: errors.map(&:attribute)).map{|f| {uuid: f.uuid, format: f.format, required: f.required}}.to_s,
          errors.map{|error| {error.attribute.to_sym => item.data[error.attribute.to_s]}}.to_s
        ]
      end
    end
  end
end

Comment on lines 16 to 20
<% if field.editor_component.present? %>
<% @item.errors.where(field.uuid).each do |error| %>
<div class="base-errors"><%= error.message %></div>
<% end %>
<% end %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je penses qu'il serait judicieux de déplacer cela dans les 2 components concernées (date et datation) car finalement ces spécifiques a ces 2 components ET l'erreur doit etre dans le form-group et non pas après.

D'ailleurs ca devrait afficher une double erreur sur un field "classique" non ? As-tu testé ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la condition if field.editor_component.present? vérifie si c'est un composant react donc pas de doublons sinon c'est potentiellement possible de passer les erreurs dans les composants react mais plus compliqué

Copy link

@skyporter skyporter May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je comprends mais il est préférable de passer l'erreur au component car le dom ne va pas la. Au moins essaier.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai passé l'erreur au composant react

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah top !

@abstracts33d abstracts33d marked this pull request as draft May 10, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants